home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_07
/
v7n7087a.txt
< prev
next >
Wrap
Text File
|
1989-09-03
|
835b
|
31 lines
Opening an Existing Block File
typedef struct { /* sequential file header */
size_t recsize; /* record size */
} shdr_t;
typedef struct { /* sequential file control structure */
shdr_t shdr; /* file header */
BLKFILE *bp; /* block file pointer */
} seq_t;
seq_t sb[SOPEN_MAX]; /* sequential file control structure table */
seq_t *sp = sb[0];
/* open sequential file */
sp->bp = bopen(filename, "r+", sizeof(shdr_t), (size_t)1, (size_t)0);
if (sp->bp == NULL);
/* error */
}
/* read file header to get record size */
rs = bgeth(sp->bp, (void *)&sp->shdr);
if (rs == -1) {
/* error */
}
/* set up buffering */
rs = bsetvbuf(sp->bp, NULL, sp->shdr.recsize, SBUFCNT);
if (rs != 0) {
/* error */
}